package com.ruoyi.project.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.project.domain.HeAnalysis;
import com.ruoyi.project.service.IHeAnalysisService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 分析报告
Controller
 * 
 * @author ruoyi
 * @date 2023-09-02
 */
@RestController
@RequestMapping("/analysis")
public class HeAnalysisController extends BaseController
{
    @Autowired
    private IHeAnalysisService heAnalysisService;

    /**
     * 查询分析报告
列表
     */
    @RequiresPermissions("project:analysis:list")
    @GetMapping("/list")
    public TableDataInfo list(HeAnalysis heAnalysis)
    {
        startPage();
        List<HeAnalysis> list = heAnalysisService.selectHeAnalysisList(heAnalysis);
        return getDataTable(list);
    }

    /**
     * 导出分析报告
列表
     */
    @RequiresPermissions("project:analysis:export")
    @Log(title = "分析报告 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HeAnalysis heAnalysis)
    {
        List<HeAnalysis> list = heAnalysisService.selectHeAnalysisList(heAnalysis);
        ExcelUtil<HeAnalysis> util = new ExcelUtil<HeAnalysis>(HeAnalysis.class);
        util.exportExcel(response, list, "分析报告数据");
    }

    /**
     * 获取分析报告
详细信息
     */
    @RequiresPermissions("project:analysis:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(heAnalysisService.selectHeAnalysisById(id));
    }

    /**
     * 新增分析报告

     */
    @RequiresPermissions("project:analysis:add")
    @Log(title = "分析报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HeAnalysis heAnalysis)
    {
        return toAjax(heAnalysisService.insertHeAnalysis(heAnalysis));
    }

    /**
     * 修改分析报告

     */
    @RequiresPermissions("project:analysis:edit")
    @Log(title = "分析报告 ", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HeAnalysis heAnalysis)
    {
        return toAjax(heAnalysisService.updateHeAnalysis(heAnalysis));
    }

    /**
     * 删除分析报告

     */
    @RequiresPermissions("project:analysis:remove")
    @Log(title = "分析报告 ", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(heAnalysisService.deleteHeAnalysisByIds(ids));
    }
}
